<template>
  <div>
    <!--<div style="height: 46px; visibility: hidden" v-show="$route.meta.isShowTabBar"></div>-->
    <van-tabbar v-model="activeTabItem" fixed placeholder route @change="onChange">
      <van-tabbar-item icon="home-o" to="/myCompany/companyHome">公司首页</van-tabbar-item>
      <van-tabbar-item icon="friends-o" :to="recruitUrl">招聘员工管理</van-tabbar-item>
      <van-tabbar-item icon="cluster-o"
                       :to="recruitUrl_upDown"
      >上下游管理</van-tabbar-item>
<!--      <van-tabbar-item icon="manager-o" to="/myCompany/companyStaffManagement">公司员工管理</van-tabbar-item>-->
    </van-tabbar>

  </div>
</template>

<script>
export default {
  name: 'comMyCompanyTarbar',
  props: ['pathStrName'],
  data(){
    return {
      activeTabItem: 'friends-o',
      //解决跳转子路由active不高亮
      recruitUrl:'/myCompany/recruitmentManagement',
      recruitUrl_upDown:'/myCompany/upstreamDownstreamManagement',
    }
  },

  watch:{
    '$route.path':function(){
    }
  },
  mounted(){
    this.updateUrl();
    this.updateUrl_forUpDown();
  },
  methods:{
    /*
      *让有子路由的选项卡保持active高亮状态
      *后续完善功能封装
    */
    updateUrl(){
      let url=this.$route.path
       //点击以下路由active--高亮
      if(url.search('recruitmentManagement')>0
        ||url.search('workInfo')>0
        ||url.search('advaceInfo')>0
        ||url.search('salary')>0
        ||url.search('blackList')>0){
          this.recruitUrl=this.$route.path
      }else{
        this.recruitUrl='/myCompany/recruitmentManagement'
      }
    },

    updateUrl_forUpDown(){
      let url=this.$route.path;
      let isUpDownPage = ['upstreamDownstreamManagement', 'invitationsIssued', 'getApplyCost', 'sendApplyCost'].some( itemStr => url.includes(itemStr));
      // console.log('是否为真', isUpDownPage, this.$route.path);

      //点击以下路由active--高亮
      if(isUpDownPage){
        // console.log('是否为真', isUpDownPage, this.$route.path);
        this.recruitUrl_upDown = this.$route.path
      }else{
        this.recruitUrl_upDown='/myCompany/upstreamDownstreamManagement'
      }
    },
    onChange(){

    },
  }
}
</script>

<style>
</style>
